﻿using System;
using System.Collections.Generic;
using System.Linq.Expressions;
using System.Threading;
using System.Threading.Tasks;

namespace WebTest.Infrastructure.Interfaces
{
    public interface IRepository<T>
    {
        Task<T> FirstOrDefault(Expression<Func<T, bool>> predicate, CancellationToken cancellationToken = default);
        Task<T> SingleOrDefault(Expression<Func<T, bool>> predicate, CancellationToken cancellationToken = default);
        Task<IReadOnlyCollection<T>> ToListAsync(Expression<Func<T, bool>> predicate = null, CancellationToken cancellationToken = default);
        Task<IReadOnlyCollection<T>> ToListAsync(int pageSize = 20, int current = 1, CancellationToken cancellationToken = default);
        bool Exists(Expression<Func<T, bool>> predicate);
        Task<bool> ExistsAsync(Expression<Func<T, bool>> predicate, CancellationToken cancellationToken = default);
        Task<T> AddAsync(T entity, CancellationToken cancellationToken = default);
        Task<IReadOnlyCollection<T>> AddRangeAsync(IEnumerable<T> entites, CancellationToken cancellationToken = default);
        Task<T> UpdateAsync(T entity, CancellationToken cancellationToken = default);
        Task DeleteAsync(T entity, CancellationToken cancellationToken = default);
        Task DeleteRangeAsync(List<int> list);
        Task<T> LastOrderAsync(CancellationToken cancellationToken = default);
    }
}
